//
//  KJTableViewSection.m
//  KJKit
//
//  Created by Tiger on 2022/6/9.
//

#import "KJTableViewSection.h"

@implementation KJTableViewSection

+ (instancetype)section {
    return [[self alloc] init];
}

- (instancetype)init {
    self = [super init];
    if (self) {
        self.headerHeight = CGFLOAT_MIN;
        self.footerHeight = CGFLOAT_MIN;
    }
    return self;
}

- (void)addItem:(__kindof KJTableViewItem *)item {
    [self.items addObject:item];
}

// 通过index插入
- (void)insertItem:(__kindof KJTableViewItem *)item withIndex:(NSUInteger)index {
    [self.items insertObject:item atIndex:index];
}

- (void)addItems:(NSArray<__kindof KJTableViewItem *> *)items {
    [self.items addObjectsFromArray:items];
}

- (void)removeItem:(__kindof KJTableViewItem *)item {
    [self.items removeObject:item];
}

- (void)removeAllItems {
    [self.items removeAllObjects];
}

- (NSMutableArray<KJTableViewItem *> *)items {
    if (!_items) {
        _items = [NSMutableArray array];
    }
    return _items;
}

@end
